﻿<%@ Page Language="C#" MasterPageFile="~/mainMasterPage.master" AutoEventWireup="true" CodeFile="viewcountry.aspx.cs" Inherits="Default2" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="WorldDomination.Net" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainInfo" Runat="Server">
<% string country = Request["country"];
   if (country == null)
   {
        string userHostIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if(userHostIpAddress == null) {
            userHostIpAddress = Request.ServerVariables["REMOTE_ADDR"];
        }

       //userHostIpAddress = "168.167.253.21";

        IPAddress ipAddress;
        if (IPAddress.TryParse(userHostIpAddress, out ipAddress))
        {
            country = ipAddress.Country(); // return value: UNITED STATES
            if(country == "BOTSWANA") 
            {
                country = "Botswana";
            }
            else if(country == "INDIA")
            {
                country = "India";
            }
            else
            {
                country = "United States";
            }
            //country = "Country:" + ipAddress.Country() + " IP:" + userHostIpAddress;
        }
        else {
            country = "United States";
        }
   }
   LinkedList<string[]> destinations = getDestionations(country);
    %>
			 	<div class="tree"><a href="#">Tours</a>  &raquo; <%=country %></div>
                <% foreach (string[] destination in destinations)
                   {
                       string destid = destination[0];
                       string name = destination[1];
                       string description = destination[2];
                       string image = destination[3];
                       %>
                <h1><%=name%><a NAME="<%=destid%>"></a></h1>
				<div class="gallery">
                	<img src="<%=image%>" width="476" height="270" /><br />
                    <p><%=description%></p>
				    <a href="inquiry.aspx?id=<%=destid%>" class="button">book it!</a>
                    <p></p>
				</div>
                <hr />
                <% } %>
</asp:Content>
    
<asp:Content ID="rightSide" ContentPlaceHolderID="rightSideInfo" Runat="Server" >

</asp:Content>


